package com.liukai.todo.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Collection;

import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * <p>
 *用户信息表
 * </p>
 *
 * @author liukai
 * @since 2021-07-30
 */
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Accessors(chain = true)
@TableName("tb_user")
@ApiModel(value = "UserInfo对象", description = "存放UserInfo")
public class UserInfo implements Serializable, UserDetails {

    private static final long serialVersionUID = 1L;

    /**
     * 用户id
     */
    @TableId(value = "userId", type = IdType.AUTO)
    @ApiModelProperty(value = "用户id")
    private Integer userId;

    /**
     * 密码
     */
    @TableField("userPass")
    @ApiModelProperty(value = "密码")
    private String userPass;

    /**
     * 用户名
     */
    @TableField("userName")
    @ApiModelProperty(value = "用户名")
    private String userName;

    /**
     * 昵称
     */
    @TableField("nickName")
    @ApiModelProperty(value = "昵称")
    private String nickName;

    /**
     * 手机
     */
    @TableField("phone")
    @ApiModelProperty(value = "手机")
    private String phone;

    @ApiModelProperty(value = "注册时间")
    @TableField("registerTime")
    private LocalDateTime registerTime;

    @ApiModelProperty(value = "用户状态——0禁用，1允许使用")
    @TableField("enable")
    private Integer enable;

    @ApiModelProperty(value = "用户在线时长")
    @TableField("onlineTime")
    private Float onlineTime;

    @ApiModelProperty(value = "头像")
    @TableField("headImg")
    private String headImg;

    @ApiModelProperty(value = "是否在线（0下线，1在线）")
    @TableField("online")
    private Integer online;

    @ApiModelProperty(value = "角色id")
    @TableField("roleId")
    private Integer roleId;

    @ApiModelProperty(value = "邮箱")
    @TableField("email")
    private String email;


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        
        return null;
    }

    @Override
    public String getPassword() {
        return userPass;
    }

    @Override
    public String getUsername() {
        return userName;
    }

    @Override
    public boolean isAccountNonExpired() {
        return false;
    }

    @Override
    public boolean isAccountNonLocked() {
        return false;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return false;
    }

    @Override
    public boolean isEnabled() {
        return enable == 1 ? true : false;
    }
}
